package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class Stock extends BaseDomain{
    private Commodity commodity;

    private Integer number;

    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("number", number);
        if (commodity!=null){
            map.put("commodityId", commodity.getId());
            map.put("commodityName", commodity.getName());
        }
        return JSONUtil.toJSONString(map);
    }
}